home *** CD-ROM | disk | FTP | other *** search
/ Trading on the Edge / Trading On The Edge - CD-ROM Toolkit (Wayzata Technology)(2031)(1994).bin / mac / Mac_Files / Software Utilities / NN PreProcessing / FINCMD.H < prev    next >
C/C++ Source or Header  |  1992-09-24  |  5KB  |  140 lines

  1. /* 21:30 03-Jan-92  (fincmd.h)  Command Line Parser Structures */
  2.  
  3. #ifndef FINCMDH
  4. #define    FINCMDH
  5.  
  6. /************************************************************************
  7.  * Copyright(C) 1992 NeuralWare, Inc.                                   *
  8.  * Penn Center West, IV-227, Pittsburgh, PA  15276                      *
  9.  *                                                                      *
  10.  * All rights reserved.  No part of this program may be reproduced,     *
  11.  * stored in a retrieval system, or tramsmitted, in any form or by any  *
  12.  * means, electronic, mechanical, photocopying, recording or otherwise  *
  13.  * without the prior written permission of the copyright owner,         *
  14.  * NeuralWare, Inc.                                                     *
  15.  ************************************************************************
  16.  */
  17.  
  18. /************************************************************************
  19.  *                                    *
  20.  *    fincmd - Command Line Parser & Action Routine Manager        *
  21.  *                                    *
  22.  ************************************************************************
  23. Tasks:
  24.     Integrate syntax errors with standard error handling system
  25.     Integrate help system with standard error handling system
  26.  */
  27.  
  28. #ifndef FAST
  29. #ifdef SUN
  30. #define    FAST    register
  31. #else
  32. #define    FAST
  33. #endif
  34. #endif
  35.  
  36. #ifndef ARGS
  37. #ifdef SUN
  38. #define    ARGS(x)    ()
  39. #else
  40. #define    ARGS(x) x
  41. #endif
  42. #endif
  43.  
  44. #ifndef ASof
  45. #define    ASof(x)    ((int)(sizeof(x)/sizeof(x[0])))
  46. #endif
  47.  
  48. typedef int (*ACTR) ARGS((struct _cmd *, long, FILE *));
  49. #define    SETBIT(x)    ( ((x)<0||31<(x))? 0:(1L<<(x)) )
  50. #define    ISBIT(x,bit)    ( ((x)&SETBIT(bit)) != 0? 1:0 )
  51.  
  52. /* --- Universal Pointer Union --- */
  53.  
  54. typedef union _uvp {        /* universal pointer union */
  55.     char    *cP;        /* character */
  56.     short    *sP;        /* short */
  57.     long    *lP;        /* long */
  58.     int        *iP;        /* int */
  59.     void    *vP;        /* void */
  60.     float    *fP;        /* float */
  61.     double    *dP;        /* double */
  62. } UVP;
  63.  
  64. /* --- Translation of literals to values and vice versa --- */
  65.  
  66. typedef struct _lit {
  67.     char    *LNameCP;    /* literal name */
  68.     double     LValueD;    /* resulting value as float */
  69. } LIT;
  70.  
  71. /* --- Control structure for a single data value --- */
  72.  
  73. typedef struct _input {
  74.     char    *IValP;        /* value pointer */
  75.     LIT        *ILitTabP;    /* literal table pointer */
  76.     char     IInFuncC;    /* input function */
  77. #define    IO_NAK        0x00    /*   no action */
  78. #define    IO_LST        0x01    /*   CLitTabP -> Input structure */
  79. #define    IO_INT        0x02    /*   integer */
  80. #define    IO_BIT        0x03    /*   integer (or of bits) */
  81. #define    IO_FLT        0x04    /*   real */
  82. #define    IO_STR        0x05    /*   quoted string */
  83. #define    IO_FNM        0x06    /*   file name */
  84. #define    IO_FLD        0x07    /*   field name */
  85. #define    IO_DTE        0x08    /*   date field */
  86. #define    IO_MASK        0x0f    /*   mask for input/output type */
  87. #define    IO_OPT        0x10    /*   optional item */
  88. #define    IO_DSP        0x20    /*   force display on action routine */
  89. #define    IO_LITONLY    0x40    /*   ONLY use literals */
  90.     char     IOutFuncC;    /* output function */
  91. #define    FMT_INTS    0x00    /*   %ld  */
  92. #define    FMT_INTU    0x01    /*   %lu  */
  93. #define    FMT_HEXU    0x02    /*   %lx  */
  94. #define    FMT_OCTU    0x03    /*   %lo  */
  95. #define    FMT_FLT0    0x04    /*   %.0f */
  96. #define    FMT_FLT1    0x05    /*   %.1f */
  97. #define    FMT_FLT2    0x06    /*   %.2f */
  98. #define    FMT_FLT3    0x07    /*   %.3f */
  99. #define    FMT_FLT4    0x08    /*   %.4f */
  100. #define    FMT_FLT5    0x09    /*   %.5f */
  101.     char     ISizeI;    /* size of item */
  102.     char     IItemsI;    /* # of items */
  103. } INPUT;
  104.  
  105. /* --- Macros for building a "INPUT" data-descriptor structure --- */
  106.  
  107. #define    IVAL( v,inf,outf,xlt) /* single value */ \
  108. { (char *)&v, (LIT *)xlt, inf, outf, sizeof(v), 1 }
  109. #define IVALA(v,inf,outf,xlt) /* array of values */ \
  110. { (char *)&v[0], (LIT *)xlt, inf, outf, sizeof(v[0]), sizeof(v)/sizeof(v[0]) }
  111. #define    ISTR( v,inf) /* string */ \
  112. { (char *)&v[0], (LIT *)0, inf, 0, sizeof(v), 1 }
  113. #define ILIST( list, inf ) /* list */ \
  114. { (char *)&list[0], 0, IO_LST|(inf), 0, 0, 0 }
  115. #define    INUL /* end of list */ { (char *)0 }
  116. #define IACTR0 /* act rtne no args */ { (char *)0, (LIT *)0, IO_DSP, 0, 0, 0 }
  117.  
  118. /* --- Command Structure --- */
  119.  
  120. typedef struct _cmd {
  121.     char    *CNameCP;    /* name of command / variable */
  122.     char    *CHelpCP;    /* description of item */
  123.     ACTR     CActRtnP;    /* action routine */
  124.     INPUT     CInS;        /* input Structure */
  125. } CMD;
  126.  
  127. /************************************************************************
  128.  *                                    *
  129.  *    Global Routines associated with fincmd.c            *
  130.  *                                    *
  131.  ************************************************************************
  132.     For examples of how to use both of these routines, see the
  133.     test routine at the end of fincmd.c.
  134.  */
  135.  
  136. int ParseLineI ARGS((char **,CMD *,FILE *,int));
  137. int PrintTableI ARGS((CMD *,FILE *,char*,int));
  138. int StoreValueI ARGS((char *,INPUT *,double));
  139. #endif    /* FINCMDH */
  140.